Skip to content

[_]: feat/enhance email address validation and availability checks#77

Merged
xabg2 merged 3 commits into
masterfrom
feat/add-taken-address-check
Jul 20, 2026
Merged

[_]: feat/enhance email address validation and availability checks#77
xabg2 merged 3 commits into
masterfrom
feat/add-taken-address-check

Conversation

@jzunigax2

Copy link
Copy Markdown
Contributor
  • Updated email address validation logic to include availability checks against the backend.
  • Introduced new rules for email address format validation and improved user feedback for taken addresses.
  • Enhanced the UI to reflect the loading state during availability checks and updated button states accordingly.
  • Added localization support for new validation messages in multiple languages.
  • Refactored related tests to cover new functionality and ensure robust validation behavior.

- Updated email address validation logic to include availability checks against the backend.
- Introduced new rules for email address format validation and improved user feedback for taken addresses.
- Enhanced the UI to reflect the loading state during availability checks and updated button states accordingly.
- Added localization support for new validation messages in multiple languages.
- Refactored related tests to cover new functionality and ensure robust validation behavior.
@jzunigax2 jzunigax2 self-assigned this Jul 18, 2026
@jzunigax2
jzunigax2 requested a review from xabg2 as a code owner July 18, 2026 05:25
@jzunigax2 jzunigax2 added the enhancement New feature or request label Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@xabg2, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 83660f74-fe10-4ec8-b1b4-42570bfeba9f

📥 Commits

Reviewing files that changed from the base of the PR and between ac8d314 and d4498fd.

📒 Files selected for processing (3)
  • src/features/identity-setup/components/SelectMailInput.tsx
  • src/features/identity-setup/hooks/emailAddressRules.test.ts
  • src/features/identity-setup/hooks/useEmailAddressValidation.ts
📝 Walkthrough

Walkthrough

Changes

Email setup now validates username format and backend availability, handles unavailable or uncertain addresses during submission, supports suggestion-specific labels, and adds localized messages and tests across the service, validation hook, UI, and rule logic.

Email availability flow

Layer / File(s) Summary
Mail availability API
src/services/sdk/mail/index.ts, src/services/sdk/mail/mail.service.test.ts, package.json
Adds and tests the typed checkAddressAvailability mail service method and updates the SDK dependency.
Availability rule contract
src/features/identity-setup/hooks/emailAddressRules.ts, src/features/identity-setup/hooks/emailAddressRules.test.ts
Adds availability states, format-only validation, suggestion-aware labels, and backend-dependent rule validity with corresponding tests.
Debounced availability validation
src/features/identity-setup/hooks/useEmailAddressValidation.ts, src/features/identity-setup/hooks/useEmailAddressValidation.test.ts
Adds domain-aware debounced checks, stale-request protection, availability state, manual checks, and canSubmit behavior.
Submission and availability rendering
src/features/identity-setup/hooks/useUpdateEmail.ts, src/features/identity-setup/components/UpdateEmail.tsx, src/features/identity-setup/components/EmailAddressRulesPanel.tsx, src/i18n/locales/*.json
Submissions await availability, duplicate submits are prevented, loading state is rendered, rule interpolation is supported, and availability messages are localized.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: xabg2, xabg2

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: email validation and availability checks.
Description check ✅ Passed The description matches the PR scope by covering validation, availability checks, UI state, localization, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-taken-address-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/identity-setup/hooks/emailAddressRules.test.ts`:
- Line 242: Rewrite the changed test descriptions using plain-language “When …,
then …” behavior statements, without naming implementation symbols. In
src/features/identity-setup/hooks/emailAddressRules.test.ts lines 242-242,
replace the isEmailAddressFormatValid suite description; in
src/features/identity-setup/hooks/useEmailAddressValidation.test.ts lines
30-188, remove hook and callback names from the affected suite and test
descriptions while preserving their behavioral meaning.
- Around line 243-252: Update the affected tests around
isEmailAddressFormatValid to follow the AAA pattern: assign each input during
Arrange, call isEmailAddressFormatValid in a separate Act statement, then assert
the stored result. Add blank lines between the Arrange, Act, and Assert sections
while preserving the existing inputs and expected outcomes.

In `@src/features/identity-setup/hooks/useEmailAddressValidation.test.ts`:
- Line 30: Update the test descriptions within the useEmailAddressValidation
suite to use “When …, then …” wording focused on user-observable situations and
outcomes. Remove references to implementation names such as the hook,
validateAddress, and checkAvailability while preserving each test’s existing
behavior and assertions.
- Around line 161-175: Add a deferred-request test for checkAvailability that
starts with one username/domain, changes the current input before the
availability promise resolves, then resolves the old request successfully and
asserts its result cannot set canSubmit to true or authorize submission. Cover
the stale-result path in useEmailAddressValidation and include the rejection
behavior if the existing test utilities support it.
- Around line 31-39: Update the test setup around beforeEach and afterEach to
call vi.restoreAllMocks() at the start of beforeEach before configuring
checkAddressAvailability.mockResolvedValue. Remove the vi.clearAllMocks() call
from afterEach while preserving fake-timer setup and restoration.

In `@src/features/identity-setup/hooks/useEmailAddressValidation.ts`:
- Around line 56-65: Update checkAvailability in useEmailAddressValidation so
requests are invalidated immediately when the username or domain changes, and
ensure a request whose requestId no longer matches latestRequestIdRef.current
returns a non-success availability state instead of its stale result. Keep
lastCheck updates restricted to the current request, and preserve the existing
valid-result behavior when the request remains current.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8e165380-9d77-4953-9e6e-e1000e9d99dd

📥 Commits

Reviewing files that changed from the base of the PR and between 573e054 and 6a1f549.

📒 Files selected for processing (13)
  • src/features/identity-setup/components/EmailAddressRulesPanel.tsx
  • src/features/identity-setup/components/UpdateEmail.tsx
  • src/features/identity-setup/hooks/emailAddressRules.test.ts
  • src/features/identity-setup/hooks/emailAddressRules.ts
  • src/features/identity-setup/hooks/useEmailAddressValidation.test.ts
  • src/features/identity-setup/hooks/useEmailAddressValidation.ts
  • src/features/identity-setup/hooks/useUpdateEmail.ts
  • src/i18n/locales/en.json
  • src/i18n/locales/es.json
  • src/i18n/locales/fr.json
  • src/i18n/locales/it.json
  • src/services/sdk/mail/index.ts
  • src/services/sdk/mail/mail.service.test.ts

Comment thread src/features/identity-setup/hooks/emailAddressRules.test.ts
Comment thread src/features/identity-setup/hooks/emailAddressRules.test.ts Outdated
Comment thread src/features/identity-setup/hooks/useEmailAddressValidation.test.ts
Comment thread src/features/identity-setup/hooks/useEmailAddressValidation.test.ts
Comment thread src/features/identity-setup/hooks/useEmailAddressValidation.test.ts
Comment thread src/features/identity-setup/hooks/useEmailAddressValidation.ts
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploying mail-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: d4498fd
Status: ✅  Deploy successful!
Preview URL: https://1d303d3d.mail-web-ea0.pages.dev
Branch Preview URL: https://feat-add-taken-address-check.mail-web-ea0.pages.dev

View logs

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
78.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@xabg2
xabg2 merged commit 66f01b3 into master Jul 20, 2026
5 of 6 checks passed
@xabg2
xabg2 deleted the feat/add-taken-address-check branch July 20, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants